#include <iostream>
#include <algorithm>
using namespace std;

const int N = 110, INF = 0x3f3f3f3f;
int f[N][N];
// 只能走2N-1个格子表示只能选择往下或者往右走
int dx[2] = {-1, 0}, dy[2] = {0, -1};

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            cin >> f[i][j];
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
        {
            int ans = INF;
            for (int k = 0; k < 2; ++k)
            {
                int xx = i + dx[k], yy = j + dy[k];
                if (xx >= 1 && xx <= n && yy >= 1 && yy <= n)
                    ans = min(ans, f[xx][yy]);
            }
            f[i][j] += ans == INF ? 0 : ans;
        }
    cout << f[n][n] << endl;
    return 0;
}